package cn.wenhe9.yygh.hosp.controller;

import cn.wenhe9.yygh.common.result.ResultResponse;
import cn.wenhe9.yygh.hosp.service.ScheduleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author DuJinliang
 * 2022/3/31
 */
@Api(tags = "排班管理")
//@CrossOrigin
@RestController
@RequestMapping("/admin/hosp/schedule")
public class ScheduleController {
    @Resource
    private ScheduleService scheduleService;

    /**
     * 查询排班规则数据
     * @param page Integer
     * @param limit Integer
     * @param hoscode String
     * @param depcode String
     * @return ResultResponse
     */
    @ApiOperation("查询排班规则数据")
    @GetMapping("/{page}/{limit}/{hoscode}/{depcode}")
    public ResultResponse getScheduleRule(
            @PathVariable(name = "page") @RequestParam(defaultValue = "1") long page,
            @PathVariable(name = "limit") @RequestParam(defaultValue = "10") long limit,
            @PathVariable(name = "hoscode") String hoscode,
            @PathVariable(name = "depcode") String depcode
    ){
        return scheduleService.findDepScheduleByPage(page, limit, hoscode, depcode);
    }

    /**
     * 根据医院编号 、 科室编号 和 工作日期 查询排班详细信息
     * @param hoscode String
     * @param depcode String
     * @param workDate String
     * @return ResultResponse
     */
    @ApiOperation("查询排班详细数据")
    @GetMapping("/detail/{hoscode}/{depcode}/{workDate}")
    public ResultResponse getScheduleRuleDetail(
            @PathVariable(name = "hoscode") String hoscode,
            @PathVariable(name = "depcode") String depcode,
            @PathVariable(name = "workDate") String workDate
    ){
        return scheduleService.getDetailSchedule(hoscode, depcode, workDate);
    }
}
